package com.steven.treatment_nurse.net;

import android.util.Log;


import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public abstract class MyCallback<T> implements Callback<T> {
  @Override
  public void onResponse(Call call, Response response) {
    String TAG = "MyCallback";
    switch (response.code()) {
      case 403:
        Log.e(TAG, "onResponse: 403" );
        break;
      case 500:
        Log.e(TAG, "onResponse: 500" );
        break;
      case 200:
        onSuccess(response);
        break;
      default:
        throw new IllegalStateException("Unexpected value: " + response.code());
    }
  }

  @Override
  public void onFailure(Call call, Throwable t) {
    onFailure(t);
  }

  protected abstract void onSuccess(Response response);


  protected abstract void onFailure(Throwable t);

}
